package com.martin.dms.services;

import java.util.List;

import com.martin.dms.model.Item;

/**
 * Service that manages the Item entity.
 * 
 * @author mtsvetkov
 */
public interface ItemService {

    /**
     * Retrieves an item.
     * 
     * @param id - the id of the item.
     * @return an item.
     */
    public Item get(long id);

    /**
     * Deletes an item.
     * 
     * @param id - the id of the item.
     */
    public void delete(long id);

    /**
     * Updates an item.
     * 
     * @param id - the id of the item.
     * @param name - the name of the item.
     * @param categoryId - the category id of the item's category. If less then 0 the item won't
     *            have an assigned category.
     * @param price - the price of the item.
     * @param description - the description of the item.
     * @param image - the image of the item.
     */
    public void update(long id, String name, long categoryId, int price, String description, byte[] image);

    /**
     * Creates an item.
     * 
     * @param name - the name of the item.
     * @param categoryId - the category id of the item's category. If less then 0 the item won't
     *            have an assigned category.
     * @param price - the price of the item.
     * @param description - the description of the item.
     * @param image - the image of the item.
     */
    public void create(String name, long categoryId, int price, String description, byte[] image);

    /**
     * Retrieves all items that has no category assigned.
     * 
     * @return a list of items.
     */
    public List<Item> getAllItemsWithNoCategoryAssigned();

    /**
     * Searches for items that match the <code>nameFilter</code>.
     * 
     * @param nameFilter - filter for names.
     * @return a list of items.
     */
    public List<Item> findByName(String nameFilter);

    /**
     * Searches for items that match the <code>nameFilter</code>. If there is a category with the
     * given <code>categoryId</code>, only items from this category are matched to the
     * <code>nameFilter</code>.
     * 
     * @param nameFilter - filter for names.
     * @param categoryId - the id of the category.
     * @return a list of items.
     */
    public List<Item> findByNameAndCategory(String nameFilter, long categoryId);
}
